package com.css.dzj.dzjfxyj.sys.log.controller;


import com.css.dzj.dzjfxyj.common.util.R;
import com.css.dzj.dzjfxyj.sys.log.entity.SysLogEntity;
import com.css.dzj.dzjfxyj.sys.log.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 系统日志
 * @author zhouCH
 */
@RestController
@RequestMapping("/sysLog")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;
    /**
     * 日志分页
     *
     * @param pageNo 当前页
     * @param pageSize 总条数
     * @return
     */
    @GetMapping(value = "/dirlog")
    public R dirLaws(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize
    ) {
        PageRequest pageRequest = PageRequest.of(pageNo, pageSize);
        Page<SysLogEntity> page = sysLogService.getPage(pageRequest);
        if (page != null) {
            return R.ok().put("page", page);
        } else {
            return R.error(500, "查询失败");
        }
    }
}
